﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MaxLeaf.DB;
using System.Data;
using System.Data.SqlClient;
using MaxLeaf.Common;

namespace MaxLeaf.DAL.K2W
{
    public class ICSaleUnCheckedDAL : IDALAction
    {
        W2K.OeSalesOrderDAL.FromType mFromType = new W2K.OeSalesOrderDAL.FromType();
        public int Add(DBAccess dbOrgK3Con, DBAccess dbDestWebReadCon, DBAccess dbDestWebWriteCon, string strKeyValue)
        {
            mFromType = GetFromType(dbOrgK3Con, strKeyValue);
            return  new K2W.OeSalesOrderDAL().Add(dbOrgK3Con, dbDestWebReadCon, dbDestWebWriteCon, strKeyValue, mFromType);
        }
        public int Update(DBAccess dbOrgK3Con, DBAccess dbDestWebReadCon, DBAccess dbDestWebWriteCon, string strKeyValue)
        {
            mFromType = GetFromType(dbOrgK3Con, strKeyValue);
            return new K2W.OeSalesOrderDAL().Update(dbOrgK3Con, dbDestWebReadCon, dbDestWebWriteCon, strKeyValue, mFromType);
        }
        public void Delete(DBAccess dbOrgK3Con, DBAccess dbDestWebReadCon, DBAccess dbDestWebWriteCon, string strKeyValue)
        {
            mFromType = GetFromType(dbOrgK3Con, strKeyValue);
            new K2W.OeSalesOrderDAL().Delete(dbOrgK3Con, dbDestWebReadCon, dbDestWebWriteCon, strKeyValue, mFromType);
        }

        private W2K.OeSalesOrderDAL.FromType GetFromType(DBAccess dbOrgK3Con, string strFInterID)
        {
            //string strSql = "select FTranType,Frob from ICSale where FInterID=@FInterID";
            //DataRow drData = dbOrgK3Con.GetDataFirstRow(strSql, new SqlParameter[]{
            //        new SqlParameter("@FInterID",strFInterID)                    
            //    });
            //if (drData != null)
            //{
            //    if ( CvtFunc.ToInt(drData["Frob"]) == -1)
            //    {
            //        return W2K.OeSalesOrderDAL.FromType.RedICSaleUnChecked;
            //    }
                 
            //}

            return W2K.OeSalesOrderDAL.FromType.ICSaleUnChecked;
        }
    }

}
